<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> 
    <title></title>
   <script src="<%=basePath %>resource/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
    <link href="<%=basePath %>resource/uilib/skins/Aqua/css/ligerui-dialog.css" rel="stylesheet" type="text/css" />
    <link href="<%=basePath %>resource/uilib/skins/Gray/css/dialog.css" rel="stylesheet" type="text/css" />
    <script src="<%=basePath %>resource/uilib/js/core/base.js" type="text/javascript"></script>
    <script src="<%=basePath %>resource/uilib/js/plugins/ligerDialog.js" type="text/javascript"></script>
    <script src="<%=basePath %>resource/js/common.js" type="text/javascript"></script>
	<script src="<%=basePath %>resource/js/LG.js" type="text/javascript"></script>
    <style type="text/css">
        *{ padding:0; margin:0;}
        body{ text-align:center; background:#CED9ED;}
        #login{ width:740px; margin:0 auto; font-size:12px;}  
        #loginlogo{ width:700px; height:100px; overflow:hidden; background:url('<%=basePath %>resource/images/login/logo.jpg') no-repeat; margin-top:50px;   }
        #loginpanel{ width:729px; position:relative;height:300px;}
        .panel-h{ width:729px; height:20px; background:url('<%=basePath %>resource/images/login/panel-h.gif') no-repeat; position:absolute; top:0px; left:0px; z-index:3;}
        .panel-f{ width:729px; height:13px; background:url('<%=basePath %>resource/images/login/panel-f.gif') no-repeat; position:absolute; bottom:0px; left:0px; z-index:3;}
        .panel-c{ z-index:2;background:url('<%=basePath %>resource/images/login/panel-c.gif') repeat-y;width:729px; height:300px;}
        .panel-c-l{ position:absolute; left:60px; top:40px;}
        .panel-c-r{ position:absolute; right:20px; top:50px; width:222px; line-height:200%; text-align:left;}
        .panel-c-l h3{ color:#556A85; margin-bottom:10px;}
        .panel-c-l td{ padding:7px;}
        
        
        .login-text{ height:24px; left:24px; border:1px solid #e9e9e9; background:#f9f9f9;}
        .login-text-focus{ border:1px solid #E6BF73;}
        .login-btn{width:114px; height:29px; color:#E9FFFF; line-height:29px; background:url('<%=basePath %>resource/images/login/login-btn.gif') no-repeat; border:none; overflow:hidden; cursor:pointer;}
        #txtUsername,#txtPassword{ width:191px;} 
        #logincopyright{ text-align:center; color:White; margin-top:50px;}
    </style>
    <script type="text/javascript">
    
    
        var FromUrl = getQueryStringByName("FromUrl");
        if (!FromUrl)
        {
            FromUrl = encodeURIComponent("index.jsp");
        }
        $(function ()
        {
        	$("#txtUsername").focus();
        	
        	$("#random").bind("click",function(){
        		var timenow = new Date().getTime();
        		$(this).attr("src","random.jsp?d="+timenow);
        	});
        	$("#random").css("cursor","pointer");
        	
            $(".login-text").focus(function ()
            {
                $(this).addClass("login-text-focus");
            }).blur(function ()
            {
                $(this).removeClass("login-text-focus");
            });

            $(document).keydown(function (e)
            {
                if (e.keyCode == 13)
                {
                    dologin();
                }
            });

            $("#btnLogin").click(function ()
            {
                dologin();
            });

                     

            function dologin()
            {
           
                var username = $.trim($("#txtUsername").val());
                var password = $.trim($("#txtPassword").val());
                var validatecode = $.trim($("#validatecode").val());
                if (username == "")
                {
                    alert('账号不能为空!');
                    $("#txtUsername").focus();
                    return;
                }
                if (password == "")
                {
                    alert('密码不能为空!');
                    $("#txtPassword").focus();
                    return;
                }
                if (validatecode == "")
                {
                    alert('验证码不能为空!');
                    $("#validatecode").focus();
                    return;
                }
                $.ajax({
                    type: 'post', cache: false, dataType: 'json',
                    timeout:4000,
                    url: '<%=basePath%>sysLogin/doLogin.do',
                    data: {username:username,password:password,validatecode:validatecode},
                    success: function (result)
                    {
                    	if(result=='-1'){
                    		 alert('验证码错误!');
                    		 var timenow = new Date().getTime();
         					 document.getElementById("random").src="random.jsp?d="+timenow;
                    		 $("#validatecode").focus();
                             return;
                    	}else if(result=='0'){
                    		 alert('用户名或者密码错误!');
                             return;
                    	}else if(result=='1'){
                    		location.href = decodeURIComponent(FromUrl);
                    	}else{
                    		alert('发送系统错误,请与系统管理员联系!');
                    		return;
                    	}
                    },
                    
                    error: function ()
                    {                	
                  		alert('请求时间超时,请重新登录!');
                        window.location.href =  window.location.href; 
                    },
                    beforeSend: function ()
                    {
                        $.ligerDialog.waitting("正在登录中,请稍后...");
                        $("#btnLogin").attr("disabled", true);
                    },
                    complete: function ()
                    {
                        $.ligerDialog.closeWaitting();
                        $("#btnLogin").attr("disabled", false);
                    }
                });
            }
        });
    </script>
</head>
<body style="padding:10px">
		<div id="login">
			 
			<div id="loginpanel">
				<div class="panel-h"></div>
				<div class="panel-c">
					<div class="panel-c-l">

						<table cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<td align="left" colspan="3">
										<h3>
											
										</h3>
									</td>
								</tr>
								<tr>
									<td align="right">
										账号：
									</td>
									<td align="left" colspan="2">
										<input type="text" name="loginusername" id="txtUsername"
											class="login-text" />
									</td>
								</tr>
								<tr>
									<td align="right">
										密码：
									</td>
									<td align="left" colspan="2">
										<input type="password" name="loginpassword" id="txtPassword"
											class="login-text" />
									</td>
								</tr>
								<tr>
									<td align="right">
										验证码：
									</td>
									<td align="left">
										<input type="text" name="validatecode" id="validatecode" style="width:100px"
											class="login-text" />
										
										<!--  
										<a href="javascript:show(document.getElementById('random'))"><span style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;">验证码看不清</span></a>
										-->
									</td>
									<td>
										<img src="random.jsp" id="random" align="bottom"  hspace="5" border="0px">
									</td>
								</tr>
								<tr>
									<td align="center" colspan="3">
										<input type="button" id="btnLogin" value="登录"
											class="login-btn" />
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="panel-c-r">
						<p>
							
						</p>
						<p>
							
						</p>  
						<p>
							
						</p>
						<p>
							
						</p>
					</div>
				</div>
				<div class="panel-f"></div>
			</div>
			<div id="logincopyright">
				
			</div>
		</div>
	</body>
</html>
